USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[Groups-Insert]    Script Date: [[20120714223933]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223933]]
-- Description:	Insert record into table [dbo].[Groups]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups-Insert]
	/*@Group_RowNumber int =Null OUTPUT , 
	@Group_ID uniqueidentifier =Null  , 
	@Group_NameAr varchar(200) =Null  , 
	@Group_NameEn varchar(200) =Null  , 
	@Group_Search varchar(max) =Null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Groups](/*[Group_ID], [Group_NameAr], [Group_NameEn], [Group_Search]*/)
	VALUES     (/*@Group_ID, @Group_NameAr, @Group_NameEn, @Group_Search*/)

	/*SELECT @Group_RowNumber = [Group_RowNumber]
    FROM [dbo].[Groups]
    WHERE  ( [Group_ID] =@Group_ID )
	AND  ( [Group_NameAr] =@Group_NameAr )
	AND  ( [Group_NameEn] =@Group_NameEn )
	AND  ( [Group_Search] =@Group_Search )*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[Groups-update]    Script Date: [[20120714223933]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223933]]
-- Description:	Update record in table [dbo].[Groups]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups-update]
	/*@Group_RowNumber int =Null OUTPUT , 
	@Group_ID uniqueidentifier =Null  , 
	@Group_NameAr varchar(200) =Null  , 
	@Group_NameEn varchar(200) =Null  , 
	@Group_Search varchar(max) =Null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/**/
		Update [dbo].[Groups] SET 
		/*[Group_ID] =@Group_ID, 
		[Group_NameAr] =@Group_NameAr, 
		[Group_NameEn] =@Group_NameEn, 
		[Group_Search] =@Group_Search*/
		/*WHERE ([Group_ID] = @Group_ID)*/
	/**/

	/*SELECT @Group_RowNumber = [Group_RowNumber]
    FROM [dbo].[Groups]
	WHERE ([Group_ID] = @Group_ID)*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[Groups-Insert-Update]    Script Date: [[20120714223933]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223933]]
-- Description:	Insert OR Update record into table [dbo].[Groups]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups-Insert-Update]
	/*@Group_RowNumber int =Null OUTPUT , 
	@Group_ID uniqueidentifier =Null  , 
	@Group_NameAr varchar(200) =Null  , 
	@Group_NameEn varchar(200) =Null  , 
	@Group_Search varchar(max) =Null  , 
	@Inserted bit OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Groups] 
					/*WHERE ([Group_ID] = @Group_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Groups](/*[Group_ID], [Group_NameAr], [Group_NameEn], [Group_Search]*/)
		VALUES     (/*@Group_ID, @Group_NameAr, @Group_NameEn, @Group_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/**/
			Update [dbo].[Groups] SET 
			/*[Group_ID] =@Group_ID, 
			[Group_NameAr] =@Group_NameAr, 
			[Group_NameEn] =@Group_NameEn, 
			[Group_Search] =@Group_Search*/
			/*WHERE ([Group_ID] = @Group_ID)*/
		/**/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Group_RowNumber = [Group_RowNumber]
    FROM [dbo].[Groups]
	WHERE ([Group_ID] = @Group_ID)*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[Groups-Delete]    Script Date: [[20120714223933]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223933]]
-- Description:	delete records from table [dbo].[Groups] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups-Delete]
	/*@Group_RowNumber int =null  , 
	@Group_ID uniqueidentifier =null  , 
	@Group_NameAr varchar(200) =null  , 
	@Group_NameEn varchar(200) =null  , 
	@Group_Search varchar(max) =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Groups]
	WHERE /*( [Group_RowNumber] = ISNULL(@Group_RowNumber, [Group_RowNumber]) )
	AND ( [Group_ID] = ISNULL(@Group_ID, [Group_ID]) )
	AND ( [Group_NameAr] like ISNULL(@Group_NameAr, [Group_NameAr]) )
	AND ( [Group_NameEn] like ISNULL(@Group_NameEn, [Group_NameEn]) )
	AND ( [Group_Search] like ISNULL(@Group_Search, [Group_Search]) )*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[Groups-Select]    Script Date: [[20120714223933]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223933]]
-- Description:	select records from table [dbo].[Groups] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups-Select]
	/*@Group_RowNumber int =null  , 
	@Group_ID uniqueidentifier =null  , 
	@Group_NameAr varchar(200) =null  , 
	@Group_NameEn varchar(200) =null  , 
	@Group_Search varchar(max) =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Groups]
	WHERE /*( [Group_RowNumber] = ISNULL(@Group_RowNumber, [Group_RowNumber]) )
	AND ( [Group_ID] = ISNULL(@Group_ID, [Group_ID]) )
	AND ( [Group_NameAr] like ISNULL(@Group_NameAr, [Group_NameAr]) )
	AND ( [Group_NameEn] like ISNULL(@Group_NameEn, [Group_NameEn]) )
	AND ( [Group_Search] like ISNULL(@Group_Search, [Group_Search]) )*/
END
GO
-- =============================================
